package com.wjgl.action;

import java.util.Map;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.wjgl.domain.Institution;
import com.wjgl.service.InstitutionService;

public class AddInstitutionAction extends ActionSupport {
	private InstitutionService institutionService;
	private String institutionName;
	private String institutionAddr;
	public InstitutionService getInstitutionService() {
		return institutionService;
	}
	public void setInstitutionService(InstitutionService institutionService) {
		this.institutionService = institutionService;
	}
	public String getInstitutionName() {
		return institutionName;
	}
	public void setInstitutionName(String institutionName) {
		this.institutionName = institutionName;
	}
	public String getInstitutionAddr() {
		return institutionAddr;
	}
	public void setInstitutionAddr(String institutionAddr) {
		this.institutionAddr = institutionAddr;
	}
	@Override
	public String execute() throws Exception {
		// TODO Auto-generated method stub
		Institution ins = new Institution();
		ins.setName(institutionName);
		ins.setAddress(institutionAddr);
		ins.setState((short)1);
		ins.setLevel((short)1);
		//ActionContext ac = ActionContext.getContext();
		//Map session = ac.getSession();
		//Integer username=(String)session.get("userid");
		//System.out.println(institutionName+ ": " + institutionAddr);
		institutionService.addInstitution(ins);
		return SUCCESS;
	}
	
}
